package com.me.kafka.service;

import com.me.kafka.exception.KafkaProduceMessageException;
import org.springframework.kafka.support.SendResult;
import org.springframework.util.concurrent.FailureCallback;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.SuccessCallback;

/**
 * 生产kafka消息
 *
 * @author Wuzhiming
 */
public interface ProduceKafkaMessage {


    /**
     * 发送消息
     *
     * @param topic   消费主题
     * @param message 消息主体
     * @return
     */
    ListenableFuture<SendResult<String, String>> sendMessage(String topic, String message);

    /**
     * 带回调的发送消息
     * @param topic   消费主题
     * @param message 消息主体
     * @param successCallback 成功回调
     * @param failureCallback 失败回调
     */
    void sendMessageRollback(String topic, String message, SuccessCallback successCallback, FailureCallback failureCallback);
    /**
     * 带回调的发送消息
     * @param topic   消费主题
     * @param message 消息主体
     * @param successCallback 成功回调
     */
    void sendMessageRollback(String topic, String message, SuccessCallback successCallback);
}
